package com.soundai.skill.helloworld.handlers;

import com.amazon.ask.dispatcher.request.handler.HandlerInput;
import com.amazon.ask.dispatcher.request.handler.RequestHandler;
import com.amazon.ask.dispatcher.request.handler.impl.CanFulfillIntentRequestHandler;
import com.amazon.ask.model.Response;
import com.amazon.ask.model.canfulfill.CanFulfillIntentRequest;

import java.util.Optional;
import java.util.function.Predicate;

import static com.amazon.ask.request.Predicates.intentName;

public class HelloWorldIntentHandler implements RequestHandler { //RequestHandler ,
   @Override
    public boolean canHandle(HandlerInput input) {
        System.out.println(" HelloWorldIntent.getRequestEnvelope().toString():"+ input.getRequestEnvelope().toString());
        Predicate<HandlerInput> v= intentName("HelloWorldIntent");
        return input.matches(v);
    }

    @Override
    public Optional<Response> handle(HandlerInput input) {
        //log.writeFile("C://001.log","执行LaunchRequestHandler接口" );
        String speechText = "Hello world";
       return input.getResponseBuilder()
                .withSpeech(speechText)
                .withSimpleCard("HelloWorld", speechText)
                .build();
    }

}
